package at.ac.tuwien.prog.view.controller;

import java.util.HashSet;
import java.util.Set;

/**
 * 
 * @author christoph.pickl@student.tuwien.ac.at
 */
public class FrontController {

//	private static final FrontController INSTANCE = new FrontController();
//	
//	private FrontController() {
//		// singleton
//	}
//	
//	public static FrontController getInstance() {
//		return INSTANCE;
//	}
	
	private final Set<IFrontEventListener> eventListeners = new HashSet<IFrontEventListener>();
	
	public void addFrontEventListener(IFrontEventListener listener) {
		this.eventListeners.add(listener);
	}
	
	public boolean removeFrontEventListener(IFrontEventListener listener) {
		return this.eventListeners.remove(listener);
	}
	
	public void broadcastEvent(final FrontEvent event) {
		for (IFrontEventListener listener : this.eventListeners) {
			listener.eventDispatched(event);
		}
	}
}
